package com.code;

/**
 * 爬楼梯计算最少体力
 * Created by lucky on 2018/9/30.
 */
public class ClimbStairsAndTli {
    public static void main(String[] args) {
        int[] v = new int[]{1, 100, 1, 1, 1, 100, 1, 1, 100, 1};
        System.out.println(minCostClimbingStairs(v));
    }

    public static int minCostClimbingStairs(int[] cost) {
        int length = cost.length;
        if(length == 2){
            return Math.min(cost[0],cost[1]);
        }
        int[] dp = new int[1000+1];
        dp[0] = cost[0];
        dp[1] = cost[1];
        for (int i = 2 ; i < length; i ++){
            dp[i] = Math.min(dp[i-2],dp[i-1]) + cost[i];
        }
        return Math.min(dp[length-1],dp[length-2]);
    }
}
